﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Simulator
{
	public partial class Sheet : UserControl
	{
		public Sheet ()
		{
			InitializeComponent ();

			_comboBoxVLAN1.SelectVlan (1);
			_area.SelectVlan (1);
		}

		public PropertyGrid TreePropertyGrid
		{
			get { return _area._treePropertyGrid; }
			set { _area._treePropertyGrid = value; }
		}

		public PropertyGrid BridgeOrPortPropertyGrid
		{
			get { return _area._bridgeOrPortPropertyGrid; }
			set { _area._bridgeOrPortPropertyGrid = value; }
		}

		public Logger Logger
		{
			get { return _area._logHandler; }
			set { _area._logHandler = value; }
		}

		protected override void OnClientSizeChanged (EventArgs e)
		{
			base.OnClientSizeChanged (e);

			// workaround for anchoring / docking not working together with DPI scaling
			// http://connect.microsoft.com/VisualStudio/feedback/details/259155

			int padding = 0;
			_area.Left = padding;
			_area.Width = ClientSize.Width - padding - padding;
			_area.Height = ClientSize.Height - _area.Top - padding;
		}

		private void comboBoxVLAN1_VlanChanged (object sender, EventArgs e)
		{
			_area.SelectVlan (_comboBoxVLAN1.SelectedVlanNumber);
		}
	}
}
